<template>
  <Card title="全年数据分析">
    <div slot="extra">
      <timeType  @changeTimeType="changeTimeType"></timeType>
    </div>
    <pie :option="option"  :data="charData"></pie>
  </Card>
</template>

<script>
import pie from "../echarts/pie";
import {deviceTotal} from '@/api/realtimeData';
import base from '@/mixins/base';
import timeType from "./timeType";
export default {
  mixins:[base],
  components:{pie,timeType},
  name: "alarmEventInfo",
  data(){
    return {

      option:{
        color: ['#1cdfc0', '#ffd342', '#ff945f', '#ff0000'],

        series:[{
          name:'',
          radius: ['50%', '70%'],
        }]
      },
      charData:[]
    }
  },
  mounted() {
    this.getData();
  },
  methods:{
    async getData(){
      let res =!this.orgIds?{}: await deviceTotal({pOrgId:this.orgIds,dateType:this.dateType});
      let data=_.get(res,'data')||{}
      this.charData=[];
      if(data.all){
        this.charData=[{...data,data:[{name:'正常',value:_.get(data,'normal')||0},
            {name:'离线',value:_.get(data,'offline')||0},
            // {name:'故障',value:_.get(data,'fault')||0},
            {name:'告警',value:_.get(data,'abnormal')||0}]}]
      }
    },
  },
}
</script>

<style scoped>

</style>
